public class Demo {
    public static void main(String[] args) {
        MyBlockingQueue que = new MyBlockingQueue();

        Thread t = new Thread(() -> {
            while(true) {
                try {
                    int val =  que.take();
                    System.out.println("消费:" + val);
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();

        Thread t1 = new Thread(()->{
            int n = 0;
           while(true) {
               try {
                   que.put(n);
                   System.out.println("生产:" + n);
                   n++;
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        });

        t1.start();
    }
}
